//
//  CZStatusModel.swift
//  sinaSwifWeiBo
//
//  Created by 张雪雪 on 16/3/2.
//  Copyright © 2016年 张雪雪. All rights reserved.
//

import UIKit

class CZStatusModel: NSObject {
    
    //id	int64	微博ID
    var id: Int = 0
    // created_at string 微博的创建时间
    var created_at: String?
    //微博信息的内容
    var text: String?
    //soure: string 微博的来源
    var source:String?
    
    
    ///reposts_count	int	转发数
    var reposts_count: Int = 0
    ///comments_count	int	评论数
    var comments_count: Int = 0
    ///attitudes_count	int	表态数
    var attitudes_count: Int = 0
    
    ///retweeted_status	object	被转发的原微博信息字段，当该微博为转发微博时返回 详细
    var retweeted_status: CZStatusModel?
    
    
    //定义一个数组,注意一定要初始化
    var pic_urls:[CZPictureModel]?
    
    
    //用户模型
    var user:CZStatusUserModel?
    
    init(dic: [String : NSObject] ) {
        
        super.init()
        
        //调用kvc
        setValuesForKeysWithDictionary(dic)
        
        if let userDic = dic["user"] as? [String: NSObject]{
        
          //获取到user 的字典然后进行字典转模型
            user = CZStatusUserModel(dic: userDic)
        
        }
        
        if let retweetDic = dic["retweeted_status"] as? [String:NSObject]{
        
        
            retweeted_status = CZStatusModel(dic:retweetDic)
        
        }
        
        if let pic_URLS = dic["pic_urls"] as? [[String : NSObject]]{
        
        //便利数组
            pic_urls = [CZPictureModel]()
            
            //便利字典转模型
            for info in pic_URLS{
            
                pic_urls?.append(CZPictureModel(dic: info))
            
            }
        
        }
        
        
        
    }
    //放置崩溃
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    

}
